home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / GAS211S2.ZIP / src / gas-211 / include / ansidecl.h next >
C/C++ Source or Header  |  1993-05-30  |  4KB  |  137 lines

  1. /* ANSI and traditional C compatability macros
  2.    Copyright 1991, 1992 Free Software Foundation, Inc.
  3.    This file is part of the GNU C Library.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* ANSI and traditional C compatibility macros
  20.  
  21.    ANSI C is assumed if __STDC__ is #defined.
  22.  
  23.    Macro    ANSI C definition    Traditional C definition
  24.    -----    ---- - ----------    ----------- - ----------
  25.    PTR        `void *'        `char *'
  26.    LONG_DOUBLE    `long double'        `double'
  27.    VOLATILE    `volatile'        `'
  28.    SIGNED    `signed'        `'
  29.    PTRCONST    `void *const'        `char *'
  30.  
  31.    CONST is also defined, but is obsolete.  Just use const.
  32.  
  33.    DEFUN (name, arglist, args)
  34.  
  35.     Defines function NAME.
  36.  
  37.     ARGLIST lists the arguments, separated by commas and enclosed in
  38.     parentheses.  ARGLIST becomes the argument list in traditional C.
  39.  
  40.     ARGS list the arguments with their types.  It becomes a prototype in
  41.     ANSI C, and the type declarations in traditional C.  Arguments should
  42.     be separated with `AND'.  For functions with a variable number of
  43.     arguments, the last thing listed should be `DOTS'.
  44.  
  45.    DEFUN_VOID (name)
  46.  
  47.     Defines a function NAME, which takes no arguments.
  48.  
  49.    obsolete --     EXFUN (name, (prototype))    -- obsolete.
  50.  
  51.     Replaced by PARAMS.  Do not use; will disappear someday soon.
  52.     Was used in external function declarations.
  53.     In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
  54.     parentheses).  In traditional C it is `NAME()'.
  55.     For a function that takes no arguments, PROTOTYPE should be `(void)'.
  56.  
  57.     PARAMS ((args))
  58.  
  59.     We could use the EXFUN macro to handle prototype declarations, but
  60.     the name is misleading and the result is ugly.  So we just define a
  61.     simple macro to handle the parameter lists, as in:
  62.  
  63.           static int foo PARAMS ((int, char));
  64.  
  65.     This produces:  `static int foo();' or `static int foo (int, char);'
  66.  
  67.     EXFUN would have done it like this:
  68.  
  69.           static int EXFUN (foo, (int, char));
  70.  
  71.     but the function is not external...and it's hard to visually parse
  72.     the function name out of the mess.   EXFUN should be considered
  73.     obsolete; new code should be written to use PARAMS.
  74.  
  75.     For example:
  76.     extern int printf PARAMS ((CONST char *format DOTS));
  77.     int DEFUN(fprintf, (stream, format),
  78.           FILE *stream AND CONST char *format DOTS) { ... }
  79.     void DEFUN_VOID(abort) { ... }
  80. */
  81.  
  82. #ifndef    _ANSIDECL_H
  83.  
  84. #define    _ANSIDECL_H    1
  85.  
  86.  
  87. /* Every source file includes this file,
  88.    so they will all get the switch for lint.  */
  89. /* LINTLIBRARY */
  90.  
  91.  
  92. #if defined (__STDC__) || defined (_AIX)
  93. /* All known AIX compilers implement these things (but don't always define
  94.    __STDC__).  */
  95.  
  96. #define    PTR        void *
  97. #define    PTRCONST    void *CONST
  98. #define    LONG_DOUBLE    long double
  99.  
  100. #define    AND        ,
  101. #define    NOARGS        void
  102. #define    CONST        const
  103. #define    VOLATILE    volatile
  104. #define    SIGNED        signed
  105. #define    DOTS        , ...
  106.  
  107. #define    EXFUN(name, proto)        name proto
  108. #define    DEFUN(name, arglist, args)    name(args)
  109. #define    DEFUN_VOID(name)        name(void)
  110.  
  111. #define PROTO(type, name, arglist)    type name arglist
  112. #define PARAMS(paramlist)        paramlist
  113.  
  114. #else    /* Not ANSI C.  */
  115.  
  116. #define    PTR        char *
  117. #define    PTRCONST    PTR
  118. #define    LONG_DOUBLE    double
  119.  
  120. #define    AND        ;
  121. #define    NOARGS
  122. #define    CONST
  123. #define    const
  124. #define    VOLATILE
  125. #define    SIGNED
  126. #define    DOTS
  127.  
  128. #define    EXFUN(name, proto)        name()
  129. #define    DEFUN(name, arglist, args)    name arglist args;
  130. #define    DEFUN_VOID(name)        name()
  131. #define PROTO(type, name, arglist) type name ()
  132. #define PARAMS(paramlist)        ()
  133.  
  134. #endif    /* ANSI C.  */
  135.  
  136. #endif    /* ansidecl.h    */
  137.